package com.auto.survey.activity.monitoring.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.auto.survey.R

class CtrlStartMeasureAdapter : RecyclerView.Adapter<CtrlStartMeasureAdapter.CtrlStartMeasureViewHodler>(){

    private val measureLogList = mutableListOf<String>()
    fun setItems(datas: MutableList<String>) {
        measureLogList.clear()
        measureLogList.addAll(datas)
        notifyDataSetChanged()
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CtrlStartMeasureViewHodler {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.adapter_ctrl_startmeasure, parent, false)
        return CtrlStartMeasureViewHodler(view)
    }

    override fun onBindViewHolder(holder: CtrlStartMeasureViewHodler, position: Int) {
        holder.textview.text = measureLogList[position]
    }

    override fun getItemCount(): Int {
        return measureLogList.size
    }


    inner class CtrlStartMeasureViewHodler(itemView: View): RecyclerView.ViewHolder(itemView){
        val textview = itemView.findViewById<TextView>(R.id.tv_item_start_measures)
    }
}